#!/bin/bash

if [ -z "$1" ]
then
	
	echo
	echo Specify target BTRFS volume UUID
	echo
	exit
fi

umount -q /mnt/root
mkdir -p /mnt/root

if ! ( mount -o subvolid=0 UUID=$1 /mnt/root )
then
	exit
fi

cd /mnt/root

echo
echo btrfs subvolume list .
echo mv @_old_name @_new_name
echo btrfs subvolume delete @_subvolume
echo exit
echo

btrfs subvolume list /mnt/root
bash

cd /mnt

umount /mnt/root
